package example.demo.component;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.Lifecycle;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RunnerBean implements CommandLineRunner, ApplicationRunner, Lifecycle {
    @Override
    public void run(String... args) throws Exception {
        log.info("{}==========调用============{}", this.getClass().getSimpleName(), "CommandLineRunner.run");
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("{}==========调用============{}", this.getClass().getSimpleName(), "ApplicationRunner.run");
    }

    @Override
    public void start() {
        log.info("{}==========调用============{}", this.getClass().getSimpleName(), "Lifecycle.start");
    }

    @Override
    public void stop() {
        log.info("{}==========调用============{}", this.getClass().getSimpleName(), "Lifecycle.stop");
    }

    @Override
    public boolean isRunning() {
        log.info("{}==========调用============{}", this.getClass().getSimpleName(), "Lifecycle.isRunning");
        return false;
    }
}
